package com.dodayum.service.impl;

import com.dodayum.dao.WebsiteMapper;
import com.dodayum.pojo.Website;
import com.dodayum.service.WebsiteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Service
public class WebSiteServiceImpl implements WebsiteService {

    @Resource
    WebsiteMapper websiteMapper;

    @Override
    public void test01() {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        String name = "apple";
        for (int i = 0; i < 5; i++) {
            executorService.execute(() -> input(name));
        }
    }

    private void input(String name) {
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            websiteMapper.insert(new Website().setName(name + i).setUrl("www.apple" + i + ".com"));
        }
    }

}
